package com.lingkang.ngfile.controller;

import com.lingkang.ngfile.common.RequestUtils;
import com.lingkang.ngfile.dto.ResponseResult;
import com.lingkang.ngfile.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author linke
 * @date 2020-02-08 下午 21:36
 * @description
 */
@Controller
public class FileController {
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private FileService fileService;

    /**
     * 公开的上传
     */
    @PostMapping("/public/up")
    @ResponseBody
    public ResponseResult publicUp(MultipartFile[] files) throws Exception {
        return fileService.publicUp(files, RequestUtils.getIpAddress(request));
    }

    /**
     * 用户才可上传
     */
    @PostMapping("/user/up")
    @ResponseBody
    public String UserUp() {
        return null;
    }


}
